//
//  MPVersionViewCell.m
//  MobileProject
//
//  Created by caiqilin on 2017/6/23.
//  Copyright © 2017年 caiqilin. All rights reserved.
//

#import "MPVersionViewCell.h"

@implementation MPVersionViewCell
+ (instancetype)cellWithTableView:(UITableView *)tableView {
    // 1.确定重用标示:
    static NSString *ID = @"version";
    
    // 2.从缓存池中取
    MPVersionViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    
    // 3.如果空就手动创建
    if (!cell) {
        cell = [[MPVersionViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    
    return cell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        //        self.imageView.contentMode = UIViewContentModeScaleAspectFit;
        self.textLabel.textColor = [UIColor darkGrayColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        //        self.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow"]];
        self.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mainCellBackground"]];
        UILabel *rightLabel = [[UILabel alloc] init];
        rightLabel.textAlignment = NSTextAlignmentRight;
        [self addSubview:rightLabel];
        self.rightLabel = rightLabel;
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
//    
//    if (self.imageView.image == nil) return;
//    
//    // imageView
//    self.imageView.ex_y = MPSmallMargin;
//    self.imageView.ex_height = self.contentView.ex_height - 2 * MPSmallMargin;
//    self.imageView.ex_width = self.imageView.ex_height;
//    
    // imageView
    self.rightLabel.ex_y = MPSmallMargin;
    self.rightLabel.ex_height = self.contentView.ex_height - 2 * MPSmallMargin;
//    self.rightLabel.ex_width = self.rightLabel.ex_height;
    self.rightLabel.ex_width = 100;
    self.rightLabel.ex_x = SCREEN_WIDTH - 10 - self.rightLabel.ex_width;
    
    // label
    self.textLabel.ex_x = 20;
}

@end
